package day16;

public class AbstractFactory {
    ProductA createObjectA() {
        return null;
    }

    ProductB createObjectB() {
        return null;
    }
}

class Factory1 extends AbstractFactory {
    public ProductA createObject() {
        return new GoodsA2();
    }
    public ProductB createObjectB() {
        return new GoodsB2();
    }
}

class Factory2 extends AbstractFactory {
    public ProductA createObject() {
        return new GoodsA1();
    }
    public ProductB createObjectB() {
        return new GoodsB1();
    }

    public static void main(String[] args) {
        AbstractFactory factory1 = new Factory1();
        ProductA pA = factory1.createObjectA();
        ProductB pB = factory1.createObjectB();
        pA.product();
        pB.product();
    }
}


interface ProductA {
    void product();
}

class  GoodsA1 implements ProductA {
    public void product() {
        System.out.println("生产A(低配)");
    }
}

class  GoodsA2 implements ProductA {
    public void product() {
        System.out.println("生产A(低配)");
    }
}

interface ProductB {
    void product();
}

class  GoodsB1 implements ProductB {
    public void product() {
        System.out.println("生产B(低配)");
    }
}

class  GoodsB2 implements ProductB {
    public void product() {
        System.out.println("生产B(低配)");
    }
}